<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/* sidebar menu */
if (!function_exists('get_common_sidebar')) {
	function get_common_sidebar() {
		$anchors = array(
			array('link' => 'home/index', 'title' => 'Home')
		);
		return $anchors;
	}
}

if (!function_exists('get_user_sidebar')) {
	function get_user_sidebar($role, $menu, $query = '') {
		switch ($role) {
		case ROLE_MAHASISWA:
			return call_user_func('get_mahasiswa_sidebar', $menu);
			break;
		case ROLE_MAHALUM:
			return call_user_func('get_mahalum_sidebar', $menu, $query);
			break;
		case ROLE_SPONSOR:
			return call_user_func('get_sponsor_sidebar', $menu, $query);
			break;
		case ROLE_ADKESMA:
			return call_user_func('get_adkesma_sidebar', $menu, $query);
			break;
		}
		return FALSE;
	}
}

if (!function_exists('get_mahasiswa_sidebar')) {
	function get_mahasiswa_sidebar($menu) {
		$anchors = array();
		switch ($menu) {
		case 'home':
			$anchors[] = array('link' => 'mahasiswa/home/lists', 'title' => 'Daftar Pengumuman');
			break;
		case 'profile':
			$anchors[] = array('link' => 'mahasiswa/profile/index', 'title' => 'Data Diri');
			$anchors[] = array('link' => 'mahasiswa/profile/achievement', 'title' => 'Daftar Prestasi');
			$anchors[] = array('link' => 'mahasiswa/profile/organization', 'title' => 'Kegiatan Organisasi');
			$anchors[] = array('link' => 'mahasiswa/profile/document', 'title' => 'Daftar Berkas');
			$anchors[] = array('link' => 'mahasiswa/profile/story', 'title' => 'Cerita Singkat');
			break;
		case 'scholarship':
			$anchors[] = array('link' => 'mahasiswa/scholar/index', 'title' => 'Daftar Beasiswa Ditawarkan');
			$anchors[] = array('link' => 'mahasiswa/scholar/obtained', 'title' => 'Daftar Beasiswa Diterima');
		}
		return $anchors;
	}
}

if (!function_exists('get_mahalum_sidebar')) {
	function get_mahalum_sidebar($menu, $query = '') {
		$anchors = array();
		switch ($menu) {
		case 'home':
			$anchors[] = array('link' => 'mahalum/home/lists', 'title' => 'Daftar Pengumuman');
			$anchors[] = array('link' => 'mahalum/home/add', 'title' => 'Tambah Pengumuman');
			break;
		case 'studentlist':
			$anchors[] = array('link' => 'mahalum/student/search', 'title' => 'Daftar Mahasiswa');
			break;
		case 'student':
			$anchors[] = array('link' => 'mahalum/student/profile/index'.$query,'title' => 'Data Diri');
			$anchors[] = array('link' => 'mahalum/student/profile/achievement'.$query, 'title' => 'Daftar Prestasi');
			$anchors[] = array('link' => 'mahalum/student/profile/organization'.$query, 'title' => 'Kegiatan Organisasi');
			$anchors[] = array('link' => 'mahalum/student/profile/document'.$query, 'title' => 'Daftar Berkas');
			$anchors[] = array('link' => 'mahalum/student/profile/history'.$query, 'title' => 'Riwayat Akademis');
			$anchors[] = array('link' => 'mahalum/student/profile/story'.$query, 'title' => 'Cerita Singkat');
			break;
		case 'scholarship':
			$anchors[] = array('link' => 'mahalum/scholar/offer/index', 'title' => 'Daftar Beasiswa yang Ditawarkan');
			$anchors[] = array('link' => 'mahalum/scholar/selection/index', 'title' => 'Daftar Seleksi Beasiswa');
			$anchors[] = array('link' => 'mahalum/scholar/active/index', 'title' => 'Daftar Beasiswa Aktif');
			$anchors[] = array('link' => 'mahalum/scholar/nonactive/index', 'title' => 'Daftar Beasiswa Non-Aktif');
			break;
		case 'sponsor':
			$anchors[] = array('link' => 'mahalum/sponsor/add', 'title' => 'Tambah Sponsor');
//			$anchors[] = array('link' => 'mahalum/sponsor/index', 'title' => 'Daftar Sponsor');
			break;
		}
		return $anchors;
	}
}

if (!function_exists('get_adkesma_sidebar')) {
	function get_adkesma_sidebar($menu, $query = '') {
		$anchors = array();
		switch ($menu) {
		case 'home':
			$anchors[] = array('link' => 'adkesma/home/lists', 'title' => 'Daftar Pengumuman');
			$anchors[] = array('link' => 'adkesma/home/add', 'title' => 'Tambah Pengumuman');
			break;
		case 'studentlist':
			$anchors[] = array('link' => 'adkesma/student/search', 'title' => 'Daftar Mahasiswa');
			break;
		case 'student':
			$anchors[] = array('link' => 'adkesma/student/profile/index'.$query,'title' => 'Data Diri');
			$anchors[] = array('link' => 'adkesma/student/profile/achievement'.$query, 'title' => 'Daftar Prestasi');
			$anchors[] = array('link' => 'adkesma/student/profile/organization'.$query, 'title' => 'Kegiatan Organisasi');
			$anchors[] = array('link' => 'adkesma/student/profile/document'.$query, 'title' => 'Daftar Berkas');
			$anchors[] = array('link' => 'adkesma/student/profile/history'.$query, 'title' => 'Riwayat Akademis');
			$anchors[] = array('link' => 'adkesma/student/profile/story'.$query, 'title' => 'Cerita Singkat');
			break;
		case 'scholarship':
			$anchors[] = array('link' => 'adkesma/scholar/offer/index', 'title' => 'Daftar Beasiswa yang Ditawarkan');
			$anchors[] = array('link' => 'adkesma/scholar/selection/index', 'title' => 'Daftar Seleksi Beasiswa');
			$anchors[] = array('link' => 'adkesma/scholar/active/index', 'title' => 'Daftar Beasiswa Aktif');
			$anchors[] = array('link' => 'adkesma/scholar/nonactive/index', 'title' => 'Daftar Beasiswa Non-Aktif');
			break;
		case 'sponsor':
			$anchors[] = array('link' => 'adkesma/sponsor/add', 'title' => 'Tambah Sponsor');
//			$anchors[] = array('link' => 'adkesma/sponsor/index', 'title' => 'Daftar Sponsor');
			break;
		}
		return $anchors;
	}
}

if (!function_exists('get_sponsor_sidebar')) {
	function get_sponsor_sidebar($menu, $query = '') {
		$anchors = array();
		switch ($menu) {
		case 'home':
			$anchors[] = array('link' => 'sponsor/home/lists', 'title' => 'Daftar Pengumuman');
			break;
		case 'studentlist':
			$anchors[] = array('link' => 'sponsor/student/search', 'title' => 'Daftar Mahasiswa');
			break;
		case 'student':
			$anchors[] = array('link' => 'sponsor/student/profile/index'.$query,'title' => 'Data Diri');
			$anchors[] = array('link' => 'sponsor/student/profile/achievement'.$query, 'title' => 'Daftar Prestasi');
			$anchors[] = array('link' => 'sponsor/student/profile/organization'.$query, 'title' => 'Kegiatan Organisasi');
			$anchors[] = array('link' => 'sponsor/student/profile/document'.$query, 'title' => 'Daftar Berkas');
			$anchors[] = array('link' => 'sponsor/student/profile/history'.$query, 'title' => 'Riwayat Akademis');
			$anchors[] = array('link' => 'sponsor/student/profile/story'.$query, 'title' => 'Cerita Singkat');
			break;
		case 'scholarship':
			$anchors[] = array('link' => 'sponsor/scholar/index', 'title' => 'Daftar Beasiswa yang Ditawarkan');
			$anchors[] = array('link' => 'sponsor/scholar/selection', 'title' => 'Daftar Seleksi Beasiswa');
			$anchors[] = array('link' => 'sponsor/scholar/active', 'title' => 'Daftar Beasiswa Aktif');
			$anchors[] = array('link' => 'sponsor/scholar/nonactive', 'title' => 'Daftar Beasiswa Non-Aktif');
			break;
		case 'profile':
			$anchors[] = array('link' => 'sponsor/profile/edit', 'title' => 'Edit Profil');
			$anchors[] = array('link' => 'sponsor/profile/changepassword', 'title' => 'Ganti Password');
		}
		return $anchors;
	}
}

/* navigation menu */
if (!function_exists('get_navigation')) {
	function get_navigation($userinfo) {
		if ($userinfo === NULL) {
			return call_user_func('get_common_navigation');
		} else {
			return call_user_func('get_user_navigation', $userinfo['role']);
		}
	}
}

if (!function_exists('get_common_navigation')) {
	function get_common_navigation() {
		$anchors = array(
			array('link' => 'home/index', 'title' => 'Home')
		);
		return $anchors;
	}
}

if (!function_exists('get_user_navigation')) {
	function get_user_navigation($role) {
		switch ($role) {
		case ROLE_MAHASISWA:
			return call_user_func('get_mahasiswa_navigation');
			break;
		case ROLE_MAHALUM:
			return call_user_func('get_mahalum_navigation');
			break;
		case ROLE_SPONSOR:
			return call_user_func('get_sponsor_navigation');
			break;
		case ROLE_ADKESMA:
			return call_user_func('get_adkesma_navigation');
			break;
		}
		return FALSE;
	}
}

if (!function_exists('get_mahasiswa_navigation')) {
	function get_mahasiswa_navigation() {
		$anchors = array(
			array('link' => 'mahasiswa/home/index', 'title' => 'Home'),
			array('link' => 'mahasiswa/profile/index', 'title' => 'Profil'),
			array('link' => 'mahasiswa/scholar/index', 'title' => 'Beasiswa'),
//			array('link' => 'pesan', 'title' => 'Tulis Pesan')
		);
		return $anchors;
	}
}

if (!function_exists('get_mahalum_navigation')) {
	function get_mahalum_navigation() {
		$anchors = array(
			array('link' => 'mahalum/home/index', 'title' => 'Home'),
			array('link' => 'mahalum/student/search', 'title' => 'Daftar Mahasiswa'),
			array('link' => 'mahalum/scholar/offer/index', 'title' => 'Daftar Beasiswa'),
			array('link' => 'mahalum/sponsor', 'title' => 'Daftar Sponsor'),
			array('link' => 'mahalum/report', 'title' => 'Laporan')
		);
		return $anchors;
	}
}

if (!function_exists('get_adkesma_navigation')) {
	function get_adkesma_navigation() {
		$anchors = array(
			array('link' => 'adkesma/home/index', 'title' => 'Home'),
			array('link' => 'adkesma/student/search', 'title' => 'Daftar Mahasiswa'),
			array('link' => 'adkesma/scholar/offer/index', 'title' => 'Daftar Beasiswa'),
			array('link' => 'adkesma/sponsor', 'title' => 'Daftar Sponsor')
		);
		return $anchors;
	}
}

if (!function_exists('get_sponsor_navigation')) {
	function get_sponsor_navigation() {
		$anchors = array(
			array('link' => 'sponsor/home/index', 'title' => 'Home'),
			array('link' => 'sponsor/student/search', 'title' => 'Daftar Mahasiswa'),
			array('link' => 'sponsor/scholar/index', 'title' => 'Daftar Beasiswa'),
			array('link' => 'sponsor/profile', 'title' => 'Profil Sponsor') 
		);
		return $anchors;
	}
}